package com.example.messages.controller;


import com.example.messages.service.MessageService;
import com.example.messages.utils.Result;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping()
@Api(tags ="验证码获取")
public class MessageController {

    @Autowired
    MessageService messageService;

    @ApiOperation(value = "【测试后端服务是否启动】")
    @GetMapping
    public String test(){
        return "短信服务测试接口";
    }

    @ApiOperation(value = "【获取验证码】")
    @ApiResponses({
            @ApiResponse(code = 200, message = "发送验证码成功" ),
            @ApiResponse(code = 400, message = "请求失败，验证码发送异常或该手机号已经发送过验证码")
    })
    @GetMapping("/code/{phone}")
    public Result getCode(@ApiParam(value = "获取验证码的手机号",required = true) @PathVariable("phone") String phone1){
        return messageService.getCode(phone1);
    }

}
